package com.hjq.mallsearch.thread;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @auther HJQ
 */
public class threaMain {
    public static ExecutorService pool= Executors.newFixedThreadPool(20);

    public static void gmain(String[] args) throws ExecutionException, InterruptedException {
        CompletableFuture.runAsync(()->{
            System.out.println("run开始:"+"5 / 2");

        },pool);
        CompletableFuture<Double> future = CompletableFuture.supplyAsync(() -> {
            System.out.println("supply开始:" + "5 / 2");
            return 5.0/ 2;
        }, pool).whenComplete((result,exception)->{
            System.out.println("完成了：" + "supply的结果为" + result);

        });
        //Double aDouble = future.get();
        //System.out.println(aDouble);
    }
}
